let path = require('path');
const webpack= require('webpack');
let ExtractTextPlugin = require("extract-text-webpack-plugin");
let HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
    entry: ['es5-shim','babel-polyfill',path.resolve(__dirname,'./src/index.js') ],
    devServer:{
        // contentBase:'./dist',//不知道这个干嘛用的
        port:'8081',
        // inline:true,
        // hot:true
    },
    module:{
        rules:[{
            test:/\.(js|jsx)$/,
            use:{
                loader:'babel-loader',
                options:{
                    presets:['es2015','react'],
                    plugins:[
                        'transform-remove-strict-mode',
                        ["transform-class-properties", { "spec": true }],
                        ["import", { "libraryName": "antd", "libraryDirectory": "es", "style": "css" }]
                    ]
                }
            },
            exclude:/node_modules/
        },
        {
            test:/\.(css|less)$/,
            use:ExtractTextPlugin.extract({
              use:[{
                loader:'css-loader',
                options:{
                  minimize:true
                }
              }, 'less-loader']
            }),
          },
          {
            test:/\.(svg|ttf|woff|eot)(\?.*)?$/,
            use: [
              {
                loader:'file-loader',
                options:{
                  name:'[name].[hash:7].[ext]',
                  publicPath:'/font/',
                  outputPath:'font/'
                }
              }
            ]
          },
          {
            test:/\.(png|jpe?g|gif)(\?.*)?$/,
            use: [
              {
                loader:'file-loader',
                options:{
                  name:'[name].[hash:7].[ext]',
                  publicPath:'/images/',
                  outputPath:'images/'
                }
              }
            ]
          }]
    },
    plugins:[
        new HtmlWebpackPlugin({
            template:path.resolve(__dirname,'index.html'),
            filename:'index.html',
            favicon:'./favicon.ico'
        }),
        // new webpack.HotModuleReplacementPlugin(),
        // new webpack.NamedModulesPlugin()
        new ExtractTextPlugin("style/[name].[chunkhash].css")

    ]
}